package dao.impl;

import dao.UserDao;
import entry.User;
import util.DBHelper;

import java.util.ArrayList;

public class UserDaoImpl implements UserDao {
    DBHelper db = new DBHelper();
    /**
     * selectUser 搜索符合条件的用户
     *
     * @param user 有值的属性只有账号和密码
     * @return User 查询到的用户信息，如果没查到返回null
     * @author 闫东杰
     */
    @Override
    public User selectUser(User user) {
        String sql = "select * from user where account=? and password = ? ";
        ArrayList select = db.select(sql, User.class, user.getAccount(), user.getPassword());

        if(select.size()==0){
            System.out.println("登陆失败");
            return null;
        }
        return  (User)select.get(0);
    }

}
